/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package demo.reflection;

import demo.generic.*;
import demo.collection.*;

/**
 *
 * @author VANDH
 */
public class Dog extends Animal implements Comparable {

    private String name;
    private int age;

    public Dog() {
        soChan = 4;
    }

    public Dog(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public boolean bietBay() {
        return false;
    }

    @Override
    public boolean bietBoi() {
        return true;
    }

    @Override
    public boolean bietKeu() {
        return true;
    }

    public void boi() {
        System.out.println("Đang bơi nè...");
    }

    public void keu() {
        System.out.println("Gâu gâu...");
    }

    @Override
    public String toString() {
        return "Tên là " + name + ", " + age + " tuổi";
    }

    @Override
    public int compareTo(Object o) {
        Dog d = (Dog) o;
        if (this.age > d.getAge()) {
            return -1;
        } else if (this.age < d.getAge()) {
            return 1;
        } else {
            return 0;
        }
    }
}
